/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package nl.cloudfarming.client.geoviewer;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 * Holds the extra info of a layer, for example the transparancy value and 
 * the indication of a layer is visible or not.
 * 
 * @author Maarten Hollenga
 */
public class LayerInfo {

    private boolean selected = false;
    private boolean visible = true;
    private int transparency = 0;

    public static final String PROPERTY_SELECTED = "selected";
    public static final String PROPERTY_VISIBLE = "visible";
    public static final String PROPERTY_TRANSPARENCY = "transparency";
    private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public LayerInfo() {
    }

    public LayerInfo(boolean selected, boolean visible, int transparency) {
        this.selected = selected;
        this.visible = visible;
        this.transparency = transparency;
    }

    /**
     * Indicates when the layer is selected or not.
     * 
     * @return Is selected or not
     */
    public boolean isSelected() {
        return selected;
    }

    /**
     * Sets a new indication of layer selected.
     * 
     * @param selected New indication of selected layer
     */
    public void setSelected(boolean selected) {
        changeSupport.firePropertyChange(PROPERTY_SELECTED, this.selected, selected);
        this.selected = selected;
    }

    /**
     * Gets the transparancy of the layer.
     * 
     * @return Transparancy
     */
    public int getTransparency() {
        return transparency;
    }

    /**
     * Sets the transparancy of the layer.
     * 
     * @param transparency New transparancy
     */
    public void setTransparency(int transparency) {
        changeSupport.firePropertyChange(PROPERTY_TRANSPARENCY, this.transparency, transparency);
        this.transparency = transparency;
    }

    /**
     * Indicates when the layer is visible or not.
     * 
     * @return Is visible or not
     */
    public boolean isVisible() {
        return visible;
    }

    /**
     * Sets a new indication of layer visible.
     * 
     * @param visible New indication of visible layer
     */
    public void setVisible(boolean visible) {
        changeSupport.firePropertyChange(PROPERTY_VISIBLE, this.visible, visible);
        this.visible = visible;
    }

    /**
     *
     * @param listener
     */
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    /**
     *
     * @param listener
     */
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
}